-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add semantic convention for specification 1.4.0 #1890
Closed
tigrannajaryan
wants to merge
1
commit into
open-telemetry:main
from
tigrannajaryan:feature/tigran/versioned-semconv
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// 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 semconv implements OpenTelemetry semantic conventions start from specification | ||
// version 1.4.0 and until the next version that introduced any changes. | ||
// | ||
// This package is currently in a pre-GA phase. Backwards incompatible changes | ||
// may be introduced in subsequent minor version releases as we work to track | ||
// the evolving OpenTelemetry specification and user feedback. | ||
// | ||
// OpenTelemetry semantic conventions are agreed standardized naming | ||
// patterns for OpenTelemetry things. This package aims to be the | ||
// centralized place to interact with these conventions. | ||
// | ||
// Example usage: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Aneurysm9 @MrAlias see this example. |
||
// | ||
// import semconv "go.opentelemetry.io/otel/semconv/v1_4_0" | ||
// ... | ||
// // Get a Tracer associcated with the Schema URL matching the semantic conventions | ||
// // that we want to use. | ||
// tracer := provider.Tracer("example_library", trace.WithSchemaURL(semconv.SchemaURL)) | ||
// ... | ||
// // Crate a Span. | ||
// var span trace.Span | ||
// _, span = tracer.Start( | ||
// context.Background(), | ||
// "operation", | ||
// // Note that here we use the semantic conventon for HostName that matches | ||
// // the Schema URL that we used in the Tracer() call. | ||
// trace.WithAttributes(semconv.HostNameKey.String("example.com")), | ||
// ) | ||
// span.End() | ||
// | ||
package v1_4_0 | ||
|
||
// Note: semantic conventions are immutable. They can only change if a new specification | ||
// version is introduced. If you need to change a semantic convention definition in this | ||
// package it means there is a new specification version that introduced the change. | ||
// In that case copy this package, give it a new name that corresponds to the new version | ||
// number and modify the semantic convention definitions. | ||
// Important: make sure to update SchemaURL string correspondingly. |
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,41 @@ | ||
// 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 v1_4_0 | ||
|
||
import ( | ||
"go.opentelemetry.io/otel/semconv" | ||
) | ||
|
||
// Semantic conventions for exception attribute keys. | ||
const ( | ||
// The Go type containing the error or exception. | ||
ExceptionTypeKey = semconv.ExceptionEscapedKey | ||
|
||
// The exception message. | ||
ExceptionMessageKey = semconv.ExceptionMessageKey | ||
|
||
// A stacktrace as a string. This most commonly will come from | ||
// "runtime/debug".Stack. | ||
ExceptionStacktraceKey = semconv.ExceptionStacktraceKey | ||
|
||
// If the exception event is recorded at a point where it is known | ||
// that the exception is escaping the scope of the span this | ||
// attribute is set to true. | ||
ExceptionEscapedKey = semconv.ExceptionEscapedKey | ||
) | ||
|
||
const ( | ||
// ExceptionEventName is the name of the Span event representing an exception. | ||
ExceptionEventName = semconv.ExceptionEventName | ||
) |
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,51 @@ | ||
// 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 v1_4_0 | ||
|
||
import ( | ||
"net/http" | ||
|
||
"go.opentelemetry.io/otel/attribute" | ||
"go.opentelemetry.io/otel/codes" | ||
"go.opentelemetry.io/otel/semconv" | ||
) | ||
|
||
func NetAttributesFromHTTPRequest(network string, request *http.Request) []attribute.KeyValue { | ||
return semconv.NetAttributesFromHTTPRequest(network, request) | ||
} | ||
|
||
func EndUserAttributesFromHTTPRequest(request *http.Request) []attribute.KeyValue { | ||
return semconv.EndUserAttributesFromHTTPRequest(request) | ||
} | ||
|
||
func HTTPClientAttributesFromHTTPRequest(request *http.Request) []attribute.KeyValue { | ||
return semconv.HTTPClientAttributesFromHTTPRequest(request) | ||
} | ||
|
||
func HTTPServerMetricAttributesFromHTTPRequest(serverName string, request *http.Request) []attribute.KeyValue { | ||
return semconv.HTTPServerMetricAttributesFromHTTPRequest(serverName, request) | ||
} | ||
|
||
func HTTPServerAttributesFromHTTPRequest(serverName, route string, request *http.Request) []attribute.KeyValue { | ||
return semconv.HTTPServerAttributesFromHTTPRequest(serverName, route, request) | ||
} | ||
|
||
func HTTPAttributesFromHTTPStatusCode(code int) []attribute.KeyValue { | ||
return semconv.HTTPAttributesFromHTTPStatusCode(code) | ||
} | ||
|
||
func SpanStatusFromHTTPStatusCode(code int) (codes.Code, string) { | ||
return semconv.SpanStatusFromHTTPStatusCode(code) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that valid? Or should it be "Package v1_4_0 implements..."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not entirely sure. I was going off this https://pkg.go.dev/golang.org/x/sys/unix
I'm go with the other way as well.