Skip to content

Commit

Permalink
Move semantic conventions package to model/semconv (#3901)
Browse files Browse the repository at this point in the history
* Move semantic conventions package to `model/semconv`

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>

* Update README.md

Co-authored-by: Bogdan Drutu <lazy@splunk.com>
  • Loading branch information
Aneurysm9 and Bogdan Drutu authored Aug 31, 2021
1 parent 70f86c6 commit 0594aa1
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ gensemconv:
@[ "${SPECPATH}" ] || ( echo ">> env var SPECPATH is not set"; exit 1 )
@[ "${SPECTAG}" ] || ( echo ">> env var SPECTAG is not set"; exit 1 )
@echo "Generating semantic convention constants from specification version ${SPECTAG} at ${SPECPATH}"
semconvgen -o translator/conventions/${SPECTAG} -t internal/conventions/template.j2 -s ${SPECTAG} -i ${SPECPATH}/semantic_conventions/resource -p conventionType=resource
semconvgen -o translator/conventions/${SPECTAG} -t internal/conventions/template.j2 -s ${SPECTAG} -i ${SPECPATH}/semantic_conventions/trace -p conventionType=trace
semconvgen -o model/semconv/${SPECTAG} -t model/internal/semconv/template.j2 -s ${SPECTAG} -i ${SPECPATH}/semantic_conventions/resource -p conventionType=resource
semconvgen -o model/semconv/${SPECTAG} -t model/internal/semconv/template.j2 -s ${SPECTAG} -i ${SPECPATH}/semantic_conventions/trace -p conventionType=trace

# Checks that the HEAD of the contrib repo checked out in CONTRIB_PATH compiles
# against the current version of this repo.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Note: {{ attr.note | render_markdown(paragraph="{0}", code="{0}", link="{1}", em

// Code generated from semantic convention specification. DO NOT EDIT.

package conventions
package semconv

{% for semconv in semconvs -%}
{%- if semconvs[semconv].attributes | rejectattr("ref") | selectattr("is_local") | sort(attribute=fqn) | length > 0 -%}
Expand Down
6 changes: 3 additions & 3 deletions translator/conventions/README.md → model/semconv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ generate in the `SPECTAG` variable.
```console
$ make gensemconv SPECPATH=~/dev/opentelemetry-specification SPECTAG=v1.5.0
Generating semantic convention constants from specification version v1.5.0 at ~/dev/opentelemetry-specification
semconvgen -o translator/conventions/v1.5.0 -t internal/conventions/template.j2 -s v1.5.0 -i ~/dev/opentelemetry-specification/semantic_conventions/resource -p conventionType=resource
semconvgen -o translator/conventions/v1.5.0 -t internal/conventions/template.j2 -s v1.5.0 -i ~/dev/opentelemetry-specification/semantic_conventions/trace -p conventionType=trace
semconvgen -o model/semconv/v1.5.0 -t model/internal/semconv/template.j2 -s v1.5.0 -i ~/dev/opentelemetry-specification/semantic_conventions/resource -p conventionType=resource
semconvgen -o model/semconv/v1.5.0 -t model/internal/semconv/template.j2 -s v1.5.0 -i ~/dev/opentelemetry-specification/semantic_conventions/trace -p conventionType=trace
```

When generating the constants for a new version ot the specification it is important to note that only `trace.go` and
`resource.go` are generated automatically. The `schema.go` and `nonstandard.go` files should be copied from a prior
version's package and updated as appropriate. Most important will be to update the `SchemaURL` constant in `schema.go`.
version's package and updated as appropriate. Most important will be to update the `SchemaURL` constant in `schema.go`.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package conventions
package semconv

const (
InstrumentationLibraryName = "otel.library.name"
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package conventions
package semconv

// SchemaURL is the schema URL that matches the version of the semantic conventions
// that this package defines. Conventions packages starting from v1.4.0 must declare
Expand Down

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

4 changes: 2 additions & 2 deletions receiver/otlpreceiver/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import (
"go.opentelemetry.io/collector/model/otlp"
"go.opentelemetry.io/collector/model/otlpgrpc"
"go.opentelemetry.io/collector/model/pdata"
semconv "go.opentelemetry.io/collector/model/semconv/v1.5.0"
"go.opentelemetry.io/collector/obsreport/obsreporttest"
conventions "go.opentelemetry.io/collector/translator/conventions/v1.5.0"
)

const otlpReceiverName = "receiver_test"
Expand Down Expand Up @@ -95,7 +95,7 @@ var traceJSON = []byte(`
var traceOtlp = func() pdata.Traces {
td := pdata.NewTraces()
rs := td.ResourceSpans().AppendEmpty()
rs.Resource().Attributes().UpsertString(conventions.AttributeHostName, "testHost")
rs.Resource().Attributes().UpsertString(semconv.AttributeHostName, "testHost")
span := rs.InstrumentationLibrarySpans().AppendEmpty().Spans().AppendEmpty()
span.SetTraceID(pdata.NewTraceID([16]byte{0x5B, 0x8E, 0xFF, 0xF7, 0x98, 0x3, 0x81, 0x3, 0xD2, 0x69, 0xB6, 0x33, 0x81, 0x3F, 0xC6, 0xC}))
span.SetSpanID(pdata.NewSpanID([8]byte{0xEE, 0xE1, 0x9B, 0x7E, 0xC3, 0xC1, 0xB1, 0x73}))
Expand Down
6 changes: 3 additions & 3 deletions service/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/collector/internal/collector/telemetry"
"go.opentelemetry.io/collector/internal/obsreportconfig"
semconv "go.opentelemetry.io/collector/model/semconv/v1.5.0"
"go.opentelemetry.io/collector/processor/batchprocessor"
telemetry2 "go.opentelemetry.io/collector/service/internal/telemetry"
conventions "go.opentelemetry.io/collector/translator/conventions/v1.5.0"
)

// collectorTelemetry is collector's own telemetry.
Expand Down Expand Up @@ -81,7 +81,7 @@ func (tel *colTelemetry) init(asyncErrorChannel chan<- error, ballastSizeBytes u
instanceUUID, _ := uuid.NewRandom()
instanceID = instanceUUID.String()
opts.ConstLabels = map[string]string{
sanitizePrometheusKey(conventions.AttributeServiceInstanceID): instanceID,
sanitizePrometheusKey(semconv.AttributeServiceInstanceID): instanceID,
}
}

Expand All @@ -96,7 +96,7 @@ func (tel *colTelemetry) init(asyncErrorChannel chan<- error, ballastSizeBytes u
"Serving Prometheus metrics",
zap.String("address", metricsAddr),
zap.Int8("level", int8(level)), // TODO: make it human friendly
zap.String(conventions.AttributeServiceInstanceID, instanceID),
zap.String(semconv.AttributeServiceInstanceID, instanceID),
)

mux := http.NewServeMux()
Expand Down

0 comments on commit 0594aa1

Please sign in to comment.