diff --git a/operator/builtin/input/file/config.go b/operator/builtin/input/file/config.go index 7e5734f0..23d27604 100644 --- a/operator/builtin/input/file/config.go +++ b/operator/builtin/input/file/config.go @@ -134,22 +134,22 @@ func (c InputConfig) Build(context operator.BuildContext) ([]operator.Operator, fileNameField := entry.NewNilField() if c.IncludeFileName { - fileNameField = entry.NewAttributeField("file_name") + fileNameField = entry.NewAttributeField("file.name") } filePathField := entry.NewNilField() if c.IncludeFilePath { - filePathField = entry.NewAttributeField("file_path") + filePathField = entry.NewAttributeField("file.path") } fileNameResolvedField := entry.NewNilField() if c.IncludeFileNameResolved { - fileNameResolvedField = entry.NewAttributeField("file_name_resolved") + fileNameResolvedField = entry.NewAttributeField("file.name.resolved") } filePathResolvedField := entry.NewNilField() if c.IncludeFilePathResolved { - filePathResolvedField = entry.NewAttributeField("file_path_resolved") + filePathResolvedField = entry.NewAttributeField("file.path.resolved") } op := &InputOperator{ diff --git a/operator/builtin/input/file/config_test.go b/operator/builtin/input/file/config_test.go index a9da65f2..88396682 100644 --- a/operator/builtin/input/file/config_test.go +++ b/operator/builtin/input/file/config_test.go @@ -541,7 +541,7 @@ func TestBuild(t *testing.T) { require.Equal(t, f.OutputOperators[0], fakeOutput) require.Equal(t, f.Include, []string{"/var/log/testpath.*"}) require.Equal(t, f.FilePathField, entry.NewNilField()) - require.Equal(t, f.FileNameField, entry.NewAttributeField("file_name")) + require.Equal(t, f.FileNameField, entry.NewAttributeField("file.name")) require.Equal(t, f.PollInterval, 10*time.Millisecond) }, }, diff --git a/operator/builtin/input/file/file_test.go b/operator/builtin/input/file/file_test.go index be242057..e9df054f 100644 --- a/operator/builtin/input/file/file_test.go +++ b/operator/builtin/input/file/file_test.go @@ -45,7 +45,7 @@ See this issue for details: https://github.com/census-instrumentation/opencensus operator.Stop() } -// AddFields tests that the `file_name` and `file_path` fields are included +// AddFields tests that the `file.name` and `file.path` fields are included // when IncludeFileName and IncludeFilePath are set to true func TestAddFileFields(t *testing.T) { t.Parallel() @@ -62,11 +62,11 @@ func TestAddFileFields(t *testing.T) { defer operator.Stop() e := waitForOne(t, logReceived) - require.Equal(t, filepath.Base(temp.Name()), e.Attributes["file_name"]) - require.Equal(t, temp.Name(), e.Attributes["file_path"]) + require.Equal(t, filepath.Base(temp.Name()), e.Attributes["file.name"]) + require.Equal(t, temp.Name(), e.Attributes["file.path"]) } -// AddFileResolvedFields tests that the `file_name_resolved` and `file_path_resolved` fields are included +// AddFileResolvedFields tests that the `file.name.resolved` and `file.path.resolved` fields are included // when IncludeFileNameResolved and IncludeFilePathResolved are set to true func TestAddFileResolvedFields(t *testing.T) { t.Parallel() @@ -102,17 +102,17 @@ func TestAddFileResolvedFields(t *testing.T) { defer operator.Stop() e := waitForOne(t, logReceived) - require.Equal(t, filepath.Base(symLinkPath), e.Attributes["file_name"]) - require.Equal(t, symLinkPath, e.Attributes["file_path"]) - require.Equal(t, filepath.Base(resolved), e.Attributes["file_name_resolved"]) - require.Equal(t, resolved, e.Attributes["file_path_resolved"]) + require.Equal(t, filepath.Base(symLinkPath), e.Attributes["file.name"]) + require.Equal(t, symLinkPath, e.Attributes["file.path"]) + require.Equal(t, filepath.Base(resolved), e.Attributes["file.name.resolved"]) + require.Equal(t, resolved, e.Attributes["file.path.resolved"]) // Clean up (linux based host) // Ignore error on windows host (The process cannot access the file because it is being used by another process.) os.RemoveAll(dir) } -// AddFileResolvedFields tests that the `file_name_resolved` and `file_path_resolved` fields are included +// AddFileResolvedFields tests that the `file.name.resolved` and `file.path.resolved` fields are included // when IncludeFileNameResolved and IncludeFilePathResolved are set to true and underlaying symlink change // Scenario: // monitored file (symlink) -> middleSymlink -> file_1 @@ -163,10 +163,10 @@ func TestAddFileResolvedFieldsWithChangeOfSymlinkTarget(t *testing.T) { defer operator.Stop() e := waitForOne(t, logReceived) - require.Equal(t, filepath.Base(symLinkPath), e.Attributes["file_name"]) - require.Equal(t, symLinkPath, e.Attributes["file_path"]) - require.Equal(t, filepath.Base(resolved1), e.Attributes["file_name_resolved"]) - require.Equal(t, resolved1, e.Attributes["file_path_resolved"]) + require.Equal(t, filepath.Base(symLinkPath), e.Attributes["file.name"]) + require.Equal(t, symLinkPath, e.Attributes["file.path"]) + require.Equal(t, filepath.Base(resolved1), e.Attributes["file.name.resolved"]) + require.Equal(t, resolved1, e.Attributes["file.path.resolved"]) // Change middleSymLink to point to file2 err = os.Remove(middleSymLinkPath) @@ -178,10 +178,10 @@ func TestAddFileResolvedFieldsWithChangeOfSymlinkTarget(t *testing.T) { writeString(t, file2, "testlog2\n") e = waitForOne(t, logReceived) - require.Equal(t, filepath.Base(symLinkPath), e.Attributes["file_name"]) - require.Equal(t, symLinkPath, e.Attributes["file_path"]) - require.Equal(t, filepath.Base(resolved2), e.Attributes["file_name_resolved"]) - require.Equal(t, resolved2, e.Attributes["file_path_resolved"]) + require.Equal(t, filepath.Base(symLinkPath), e.Attributes["file.name"]) + require.Equal(t, symLinkPath, e.Attributes["file.path"]) + require.Equal(t, filepath.Base(resolved2), e.Attributes["file.name.resolved"]) + require.Equal(t, resolved2, e.Attributes["file.path.resolved"]) // Clean up (linux based host) // Ignore error on windows host (The process cannot access the file because it is being used by another process.)