Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .chloggen/xpdata-entities-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: pdata

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add support for the new resource-entity reference API as part of the experimental xpdata package.

# One or more tracking issues or pull requests related to the change
issues: [13264]

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [api]
7 changes: 7 additions & 0 deletions pdata/internal/cmd/pdatagen/internal/base_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,21 @@ type sliceField struct {
fieldName string
originFieldName string
returnSlice baseSlice
hideAccessors bool
}

func (sf *sliceField) GenerateAccessors(ms *messageValueStruct) string {
if sf.hideAccessors {
return ""
}
t := template.Must(template.New("accessorSliceTemplate").Parse(accessorSliceTemplate))
return executeTemplate(t, sf.templateFields(ms))
}

func (sf *sliceField) GenerateAccessorsTest(ms *messageValueStruct) string {
if sf.hideAccessors {
return ""
}
t := template.Must(template.New("accessorsSliceTestTemplate").Parse(accessorsSliceTestTemplate))
return executeTemplate(t, sf.templateFields(ms))
}
Expand Down
3 changes: 2 additions & 1 deletion pdata/internal/cmd/pdatagen/internal/packages.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions pdata/internal/cmd/pdatagen/internal/pcommon_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ var resource = &messageValueStruct{
fields: []baseField{
attributes,
droppedAttributesCount,
&sliceField{
// Hide accessors for this field from 1.x public API since the proto field is experimental.
// It's available via the xpdata/entity.ResourceEntityRefs.
hideAccessors: true,
originFieldName: "EntityRefs",
returnSlice: entityRefSlice,
},
},
}

Expand Down
60 changes: 60 additions & 0 deletions pdata/internal/cmd/pdatagen/internal/xpdata_entity_package.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal"

import "path/filepath"

var xpdataEntity = &Package{
info: &PackageInfo{
name: "entity",
path: filepath.Join("xpdata", "entity"),
imports: []string{
`"go.opentelemetry.io/collector/pdata/internal"`,
`"go.opentelemetry.io/collector/pdata/pcommon"`,
`otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1"`,
`otlpresource "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1"`,
},
testImports: []string{
`"testing"`,
``,
`"github.com/stretchr/testify/assert"`,
``,
`"go.opentelemetry.io/collector/pdata/internal"`,
`"go.opentelemetry.io/collector/pdata/pcommon"`,
},
},
structs: []baseStruct{
entityRefSlice,
entityRef,
},
}

var entityRefSlice = &sliceOfPtrs{
structName: "EntityRefSlice",
packageName: "entity",
element: entityRef,
}

var entityRef = &messageValueStruct{
structName: "EntityRef",
packageName: "entity",
originFullName: "otlpcommon.EntityRef",
fields: []baseField{
schemaURLField,
&primitiveField{
fieldName: "Type",
returnType: "string",
defaultVal: `""`,
testVal: `"host"`,
},
&sliceField{
fieldName: "IdKeys",
returnSlice: stringSlice,
},
&sliceField{
fieldName: "DescriptionKeys",
returnSlice: stringSlice,
},
},
}
50 changes: 50 additions & 0 deletions pdata/internal/generated_wrapper_entityref.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions pdata/internal/generated_wrapper_entityrefslice.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pdata/internal/generated_wrapper_resource.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

92 changes: 92 additions & 0 deletions pdata/xpdata/entity/generated_entityref.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading