-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make InstrumentationLibrary<signal>ToScope functions unexported (#5164)
The functions were added in the the latest version. They are intended for the internal use only and shouldn't be exported.
- Loading branch information
Showing
11 changed files
with
157 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package otlp // import "go.opentelemetry.io/collector/model/internal/otlp" | ||
|
||
import ( | ||
otlpcommon "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" | ||
otlplogs "go.opentelemetry.io/collector/model/internal/data/protogen/logs/v1" | ||
) | ||
|
||
// InstrumentationLibraryLogsToScope implements the translation of resource logs data | ||
// following the v0.15.0 upgrade: | ||
// receivers SHOULD check if instrumentation_library_logs is set | ||
// and scope_logs is not set then the value in instrumentation_library_logs | ||
// SHOULD be used instead by converting InstrumentationLibraryLogs into ScopeLogs. | ||
// If scope_logs is set then instrumentation_library_logs SHOULD be ignored. | ||
// https://github.com/open-telemetry/opentelemetry-proto/blob/3c2915c01a9fb37abfc0415ec71247c4978386b0/opentelemetry/proto/logs/v1/logs.proto#L58 | ||
func InstrumentationLibraryLogsToScope(rls []*otlplogs.ResourceLogs) { | ||
for _, rl := range rls { | ||
if len(rl.ScopeLogs) == 0 { | ||
for _, ill := range rl.InstrumentationLibraryLogs { | ||
scopeLogs := otlplogs.ScopeLogs{ | ||
Scope: otlpcommon.InstrumentationScope{ | ||
Name: ill.InstrumentationLibrary.Name, | ||
Version: ill.InstrumentationLibrary.Version, | ||
}, | ||
LogRecords: ill.LogRecords, | ||
SchemaUrl: ill.SchemaUrl, | ||
} | ||
rl.ScopeLogs = append(rl.ScopeLogs, &scopeLogs) | ||
} | ||
} | ||
rl.InstrumentationLibraryLogs = nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package otlp // import "go.opentelemetry.io/collector/model/internal/otlp" | ||
|
||
import ( | ||
otlpcommon "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" | ||
otlpmetrics "go.opentelemetry.io/collector/model/internal/data/protogen/metrics/v1" | ||
) | ||
|
||
// InstrumentationLibraryMetricsToScope implements the translation of resource metrics data | ||
// following the v0.15.0 upgrade: | ||
// receivers SHOULD check if instrumentation_library_metrics is set | ||
// and scope_metrics is not set then the value in instrumentation_library_metrics | ||
// SHOULD be used instead by converting InstrumentationLibraryMetrics into ScopeMetrics. | ||
// If scope_metrics is set then instrumentation_library_metrics SHOULD be ignored. | ||
// https://github.com/open-telemetry/opentelemetry-proto/blob/3c2915c01a9fb37abfc0415ec71247c4978386b0/opentelemetry/proto/metrics/v1/metrics.proto#L58 | ||
func InstrumentationLibraryMetricsToScope(rms []*otlpmetrics.ResourceMetrics) { | ||
for _, rm := range rms { | ||
if len(rm.ScopeMetrics) == 0 { | ||
for _, ilm := range rm.InstrumentationLibraryMetrics { | ||
scopeMetrics := otlpmetrics.ScopeMetrics{ | ||
Scope: otlpcommon.InstrumentationScope{ | ||
Name: ilm.InstrumentationLibrary.Name, | ||
Version: ilm.InstrumentationLibrary.Version, | ||
}, | ||
Metrics: ilm.Metrics, | ||
SchemaUrl: ilm.SchemaUrl, | ||
} | ||
rm.ScopeMetrics = append(rm.ScopeMetrics, &scopeMetrics) | ||
} | ||
} | ||
rm.InstrumentationLibraryMetrics = nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package otlp // import "go.opentelemetry.io/collector/model/internal/otlp" | ||
|
||
import ( | ||
otlpcommon "go.opentelemetry.io/collector/model/internal/data/protogen/common/v1" | ||
otlptrace "go.opentelemetry.io/collector/model/internal/data/protogen/trace/v1" | ||
) | ||
|
||
// InstrumentationLibraryToScope implements the translation of resource span data | ||
// following the v0.15.0 upgrade: | ||
// receivers SHOULD check if instrumentation_library_spans is set | ||
// and scope_spans is not set then the value in instrumentation_library_spans | ||
// SHOULD be used instead by converting InstrumentationLibrarySpans into ScopeSpans. | ||
// If scope_spans is set then instrumentation_library_spans SHOULD be ignored. | ||
// https://github.com/open-telemetry/opentelemetry-proto/blob/3c2915c01a9fb37abfc0415ec71247c4978386b0/opentelemetry/proto/trace/v1/trace.proto#L58 | ||
func InstrumentationLibrarySpansToScope(rss []*otlptrace.ResourceSpans) { | ||
for _, rs := range rss { | ||
if len(rs.ScopeSpans) == 0 { | ||
for _, ils := range rs.InstrumentationLibrarySpans { | ||
scopeSpans := otlptrace.ScopeSpans{ | ||
Scope: otlpcommon.InstrumentationScope{ | ||
Name: ils.InstrumentationLibrary.Name, | ||
Version: ils.InstrumentationLibrary.Version, | ||
}, | ||
Spans: ils.Spans, | ||
SchemaUrl: ils.SchemaUrl, | ||
} | ||
rs.ScopeSpans = append(rs.ScopeSpans, &scopeSpans) | ||
} | ||
} | ||
rs.InstrumentationLibrarySpans = nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters