Skip to content
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

Add option for direct Beyla spanmetric generation #731

Merged
merged 9 commits into from
Apr 11, 2024
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
3 changes: 2 additions & 1 deletion configs/offsets/http2/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ func main() {
Addr: "0.0.0.0:8080",
Handler: handler,
}
http2.ConfigureServer(server, nil)
err := http2.ConfigureServer(server, nil)
checkErr(err, "configuring server")

roundTripExample()
fmt.Printf("Listening [0.0.0.0:8080]...\n")
Expand Down
11 changes: 9 additions & 2 deletions configs/offsets/std_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/http"
"os"
)

// This program is used to generate an executable that can be inspected by the go-offsets-tracker tool
Expand All @@ -28,9 +29,15 @@ func regularGetRequest(ctx context.Context, url string) error {
}

func main() {
regularGetRequest(context.Background(), "http://localhost:8090/rolldice")
http.ListenAndServe(":9090", http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
err := regularGetRequest(context.Background(), "http://localhost:8090/rolldice")
if err != nil {
os.Exit(1)
}
err = http.ListenAndServe(":9090", http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
// this doesn't need to have any sense!
writer.WriteHeader(request.ProtoMajor)
}))
if err != nil {
os.Exit(1)
}
}
3 changes: 3 additions & 0 deletions docs/sources/configure/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,9 @@ of Beyla: application-level metrics or network metrics.
- If the list contains `application`, the Beyla OpenTelemetry exporter exports application-level metrics;
but only if there is defined an OpenTelemetry endpoint, and Beyla was able to discover any
process matching the entries in the `discovery` section.
- If the list contains `application_span`, the Beyla OpenTelemetry exporter exports application-level trace span metrics;
but only if there is defined an OpenTelemetry endpoint, and Beyla was able to discover any
process matching the entries in the `discovery` section.
- If the list contains `network`, the Beyla OpenTelemetry exporter exports network-level
metrics; but only if there is defined an OpenTelemetry endpoint and the
[network metrics are enabled]({{< relref "../network" >}}).
Expand Down
6 changes: 5 additions & 1 deletion docs/sources/tutorial/resources/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"net/http"
"os"
"strconv"
"time"
)
Expand All @@ -27,5 +28,8 @@ func handleRequest(rw http.ResponseWriter, req *http.Request) {
}

func main() {
http.ListenAndServe(":8080", http.HandlerFunc(handleRequest))
err := http.ListenAndServe(":8080", http.HandlerFunc(handleRequest))
if err != nil {
os.Exit(1)
}
}
30 changes: 30 additions & 0 deletions pkg/internal/export/otel/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ const (
ServerPortKey = attribute.Key("server.port")
HTTPRequestBodySizeKey = attribute.Key("http.request.body.size")
HTTPResponseBodySizeKey = attribute.Key("http.response.body.size")
SpanKindKey = attribute.Key("span.kind")
SpanNameKey = attribute.Key("span.name")
StatusCodeKey = attribute.Key("status.code")
SourceKey = attribute.Key("source")
ServiceKey = attribute.Key("service")
InstanceKey = attribute.Key("instance")
)

func HTTPRequestMethod(val string) attribute.KeyValue {
Expand Down Expand Up @@ -297,3 +303,27 @@ func HTTPRequestBodySize(val int) attribute.KeyValue {
func HTTPResponseBodySize(val int) attribute.KeyValue {
return HTTPResponseBodySizeKey.Int(val)
}

func SpanKindMetric(val string) attribute.KeyValue {
return SpanKindKey.String(val)
}

func SpanNameMetric(val string) attribute.KeyValue {
return SpanNameKey.String(val)
}

func SourceMetric(val string) attribute.KeyValue {
return SourceKey.String(val)
}

func ServiceMetric(val string) attribute.KeyValue {
return ServiceKey.String(val)
}

func StatusCodeMetric(val int) attribute.KeyValue {
return StatusCodeKey.Int(val)
}

func ServiceInstanceMetric(val string) attribute.KeyValue {
return InstanceKey.String(val)
}
Loading
Loading