Skip to content

Commit d603c16

Browse files
authored
otelconf: update to latest config schema rc (#8505)
Signed-off-by: alex boten <[email protected]>
1 parent 181c7cd commit d603c16

19 files changed

+2248
-1109
lines changed

.lycheeignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ localhost:14250
66
file:///var/log/logs.jsonl
77
file:///var/log/metrics.jsonl
88
file:///var/log/traces.jsonl
9-
file:///path/to/file.jsonl
9+
file:///path/to/file.jsonl
10+
https://raw.githubusercontent.com/open-telemetry/opentelemetry.io/main/content/en/registry

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
2222

2323
- Removed the deprecated zipkin exporter example in `go.opentelemetry.io/contrib/examples/zipkin`. (#8501)
2424

25+
### Changed
26+
27+
- Updated the configuration schema used in `go.opentelemetry.io/contrib/otelconf` to [rc.3](https://github.com/open-telemetry/opentelemetry-configuration/releases/tag/v1.0.0-rc.3). (#8505)
28+
2529
<!-- Released section -->
2630
<!-- Don't change this section unless doing release -->
2731

Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,6 @@ update-all-otel-deps:
322322
# The source directory for opentelemetry-configuration schema.
323323
OPENTELEMETRY_CONFIGURATION_JSONSCHEMA_SRC_DIR=tmp/opentelemetry-configuration
324324

325-
# The SHA matching the current version of the opentelemetry-configuration schema to use
326-
OPENTELEMETRY_CONFIGURATION_JSONSCHEMA_VERSION=v1.0.0-rc.2
327-
328325
# Cleanup temporary directory
329326
genjsonschema-cleanup:
330327
rm -Rf ${OPENTELEMETRY_CONFIGURATION_JSONSCHEMA_SRC_DIR}
@@ -334,15 +331,15 @@ GENERATED_CONFIG=./otelconf/generated_config.go
334331
# Generate structs for configuration from opentelemetry-configuration schema
335332
genjsonschema: genjsonschema-cleanup $(GOJSONSCHEMA)
336333
mkdir -p ${OPENTELEMETRY_CONFIGURATION_JSONSCHEMA_SRC_DIR}
337-
curl -sSL https://api.github.com/repos/open-telemetry/opentelemetry-configuration/tarball/${OPENTELEMETRY_CONFIGURATION_JSONSCHEMA_VERSION} | tar xz --strip 1 -C ${OPENTELEMETRY_CONFIGURATION_JSONSCHEMA_SRC_DIR}
334+
curl -sSL https://api.github.com/repos/open-telemetry/opentelemetry-configuration/tarball/v1.0.0-rc.3 | tar xz --strip 1 -C ${OPENTELEMETRY_CONFIGURATION_JSONSCHEMA_SRC_DIR}
338335
$(GOJSONSCHEMA) \
339336
--capitalization ID \
340337
--capitalization OTLP \
341338
--struct-name-from-title \
342339
--package otelconf \
343340
--only-models \
344341
--output ${GENERATED_CONFIG} \
345-
${OPENTELEMETRY_CONFIGURATION_JSONSCHEMA_SRC_DIR}/schema/opentelemetry_configuration.json
342+
${OPENTELEMETRY_CONFIGURATION_JSONSCHEMA_SRC_DIR}/opentelemetry_configuration.json
346343
@echo Modify jsonschema generated files.
347344
sed -f ./otelconf/jsonschema_patch.sed ${GENERATED_CONFIG} > ${GENERATED_CONFIG}.tmp
348345
mv ${GENERATED_CONFIG}.tmp ${GENERATED_CONFIG}

otelconf/config_json.go

Lines changed: 18 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,11 @@ func (j *PushMetricExporter) UnmarshalJSON(b []byte) error {
251251
}
252252

253253
if sh.Console != nil {
254-
var c ConsoleExporter
254+
var c ConsoleMetricExporter
255255
if err := json.Unmarshal(sh.Console, &c); err != nil {
256256
return err
257257
}
258-
sh.Plain.Console = c
258+
sh.Plain.Console = &c
259259
}
260260
*j = PushMetricExporter(sh.Plain)
261261
return nil
@@ -458,47 +458,47 @@ func (j *OpenTelemetryConfiguration) UnmarshalJSON(b []byte) error {
458458
}
459459

460460
if sh.LoggerProvider != nil {
461-
var l LoggerProviderJson
461+
var l LoggerProvider
462462
if err := json.Unmarshal(sh.LoggerProvider, &l); err != nil {
463463
return errors.Join(newErrUnmarshal(j), err)
464464
}
465465
sh.Plain.LoggerProvider = &l
466466
}
467467

468468
if sh.MeterProvider != nil {
469-
var m MeterProviderJson
469+
var m MeterProvider
470470
if err := json.Unmarshal(sh.MeterProvider, &m); err != nil {
471471
return errors.Join(newErrUnmarshal(j), err)
472472
}
473473
sh.Plain.MeterProvider = &m
474474
}
475475

476476
if sh.TracerProvider != nil {
477-
var t TracerProviderJson
477+
var t TracerProvider
478478
if err := json.Unmarshal(sh.TracerProvider, &t); err != nil {
479479
return errors.Join(newErrUnmarshal(j), err)
480480
}
481481
sh.Plain.TracerProvider = &t
482482
}
483483

484484
if sh.Propagator != nil {
485-
var p PropagatorJson
485+
var p Propagator
486486
if err := json.Unmarshal(sh.Propagator, &p); err != nil {
487487
return errors.Join(newErrUnmarshal(j), err)
488488
}
489489
sh.Plain.Propagator = &p
490490
}
491491

492492
if sh.Resource != nil {
493-
var r ResourceJson
493+
var r Resource
494494
if err := json.Unmarshal(sh.Resource, &r); err != nil {
495495
return errors.Join(newErrUnmarshal(j), err)
496496
}
497497
sh.Plain.Resource = &r
498498
}
499499

500500
if sh.InstrumentationDevelopment != nil {
501-
var r InstrumentationJson
501+
var r ExperimentalInstrumentation
502502
if err := json.Unmarshal(sh.InstrumentationDevelopment, &r); err != nil {
503503
return errors.Join(newErrUnmarshal(j), err)
504504
}
@@ -530,7 +530,7 @@ func (j *OpenTelemetryConfiguration) UnmarshalJSON(b []byte) error {
530530
} else {
531531
// Configure the log level of the internal logger used by the SDK.
532532
// If omitted, info is used.
533-
sh.Plain.LogLevel = ptr("info")
533+
sh.Plain.LogLevel = ptr(SeverityNumberInfo)
534534
}
535535

536536
*j = OpenTelemetryConfiguration(sh.Plain)
@@ -689,21 +689,19 @@ func (j *OTLPGrpcExporter) UnmarshalJSON(b []byte) error {
689689

690690
// UnmarshalJSON implements json.Unmarshaler.
691691
func (j *AttributeType) UnmarshalJSON(b []byte) error {
692-
var v struct {
693-
Value any
694-
}
695-
if err := json.Unmarshal(b, &v.Value); err != nil {
692+
var v string
693+
if err := json.Unmarshal(b, &v); err != nil {
696694
return errors.Join(newErrUnmarshal(j), err)
697695
}
698696
var ok bool
699697
for _, expected := range enumValuesAttributeType {
700-
if reflect.DeepEqual(v.Value, expected) {
698+
if reflect.DeepEqual(v, expected) {
701699
ok = true
702700
break
703701
}
704702
}
705703
if !ok {
706-
return newErrInvalid(fmt.Sprintf("unexpected value type %#v, expected one of %#v)", v.Value, enumValuesAttributeType))
704+
return newErrInvalid(fmt.Sprintf("unexpected value type %#v, expected one of %#v)", v, enumValuesAttributeType))
707705
}
708706
*j = AttributeType(v)
709707
return nil
@@ -735,14 +733,14 @@ func (j *AttributeNameValue) UnmarshalJSON(b []byte) error {
735733
}
736734

737735
// json unmarshaller defaults to unmarshalling to float for int values
738-
if sh.Type != nil && sh.Type.Value == "int" {
736+
if sh.Type != nil && *sh.Type == AttributeTypeInt {
739737
val, ok := sh.Plain.Value.(float64)
740738
if ok {
741739
sh.Plain.Value = int(val)
742740
}
743741
}
744742

745-
if sh.Type != nil && sh.Type.Value == "int_array" {
743+
if sh.Type != nil && *sh.Type == AttributeTypeIntArray {
746744
m, ok := sh.Plain.Value.([]any)
747745
if ok {
748746
var vals []any
@@ -806,31 +804,6 @@ func (j *SimpleSpanProcessor) UnmarshalJSON(b []byte) error {
806804
return nil
807805
}
808806

809-
// UnmarshalJSON implements json.Unmarshaler.
810-
func (j *ZipkinSpanExporter) UnmarshalJSON(b []byte) error {
811-
type Plain ZipkinSpanExporter
812-
type shadow struct {
813-
Plain
814-
Endpoint json.RawMessage `json:"endpoint"`
815-
}
816-
var sh shadow
817-
if err := json.Unmarshal(b, &sh); err != nil {
818-
return errors.Join(newErrUnmarshal(j), err)
819-
}
820-
if sh.Endpoint == nil {
821-
return newErrRequired(j, "endpoint")
822-
}
823-
824-
if err := json.Unmarshal(sh.Endpoint, &sh.Plain.Endpoint); err != nil {
825-
return err
826-
}
827-
if sh.Timeout != nil && 0 > *sh.Timeout {
828-
return newErrGreaterOrEqualZero("timeout")
829-
}
830-
*j = ZipkinSpanExporter(sh.Plain)
831-
return nil
832-
}
833-
834807
// UnmarshalJSON implements json.Unmarshaler.
835808
func (j *NameStringValuePair) UnmarshalJSON(b []byte) error {
836809
type Plain NameStringValuePair
@@ -874,8 +847,8 @@ func (j *InstrumentType) UnmarshalJSON(b []byte) error {
874847
}
875848

876849
// UnmarshalJSON implements json.Unmarshaler.
877-
func (j *ExperimentalPeerInstrumentationServiceMappingElem) UnmarshalJSON(b []byte) error {
878-
type Plain ExperimentalPeerInstrumentationServiceMappingElem
850+
func (j *ExperimentalPeerServiceMapping) UnmarshalJSON(b []byte) error {
851+
type Plain ExperimentalPeerServiceMapping
879852
type shadow struct {
880853
Plain
881854
Peer json.RawMessage `json:"peer"`
@@ -898,7 +871,7 @@ func (j *ExperimentalPeerInstrumentationServiceMappingElem) UnmarshalJSON(b []by
898871
return errors.Join(newErrUnmarshal(j), err)
899872
}
900873

901-
*j = ExperimentalPeerInstrumentationServiceMappingElem(sh.Plain)
874+
*j = ExperimentalPeerServiceMapping(sh.Plain)
902875
return nil
903876
}
904877

0 commit comments

Comments
 (0)