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

Introduce JSON span printer #1035

Merged
merged 7 commits into from
Jul 25, 2024
Merged

Introduce JSON span printer #1035

merged 7 commits into from
Jul 25, 2024

Conversation

rafaelroquetto
Copy link
Contributor

@rafaelroquetto rafaelroquetto commented Jul 17, 2024

Introduce a new flag called BEYLA_TRACE_PRINTER, deprecate BEYLA_PRINT_TRACES, and remove BEYLA_NOOP_TRACES.

The new BEYLA_TRACE_PRINTER supersedes both BEYLA_PRINT_TRACES and BEYLA_NOOP_TRACES. It also adds two new output modes, json and json_indent as described below.

BEYLA_TRACE_PRINTER accepts the following values:

  • text equivalent to BEYLA_PRINT_TRACES=true: prints a text line with the span data
  • counter equivalent to BEYLA_TRACES_NOOP=true: prints the number of processed requests at the end of execution
  • json prints the span as a compact JSON document
  • json_indent prints the span as an indented JSON document
  • disabled - equivalent to BEYLA_PRINT_TRACES=false

Closes #344

TODO

  • tests
  • latest review comments
  • documentation

@CLAassistant
Copy link

CLAassistant commented Jul 17, 2024

CLA assistant check
All committers have signed the CLA.

@codecov-commenter
Copy link

codecov-commenter commented Jul 17, 2024

Codecov Report

Attention: Patch coverage is 97.18310% with 6 lines in your changes missing coverage. Please review.

Project coverage is 81.77%. Comparing base (5b90379) to head (2943c9a).

Files Patch % Lines
pkg/export/debug/debug.go 92.30% 4 Missing and 1 partial ⚠️
pkg/beyla/config.go 91.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1035       +/-   ##
===========================================
+ Coverage   67.49%   81.77%   +14.28%     
===========================================
  Files         139      139               
  Lines       11142    11289      +147     
===========================================
+ Hits         7520     9232     +1712     
+ Misses       3112     1541     -1571     
- Partials      510      516        +6     
Flag Coverage Δ
integration-test 56.79% <72.76%> (?)
k8s-integration-test 58.95% <54.92%> (?)
oats-test 37.05% <23.94%> (-0.40%) ⬇️
unittests 52.08% <97.18%> (+1.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@grcevski grcevski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great first PR! I left a few comments, mostly about naming and tests.

I think we should modify one of our YAML integration tests to use BEYLA_PRINT_TRACES_JSON and another which uses both BEYLA_PRINT_TRACES_JSON and BEYLA_PRINT_TRACES_JSON_INDENT.

pkg/beyla/config.go Outdated Show resolved Hide resolved
pkg/beyla/config.go Outdated Show resolved Hide resolved
pkg/internal/export/json/json.go Outdated Show resolved Hide resolved
pkg/internal/request/span.go Show resolved Hide resolved
pkg/beyla/config.go Outdated Show resolved Hide resolved
@grcevski
Copy link
Contributor

@mariomac do you think we should handle the NetO11y printer in this PR or we should follow-up with another PR? Perhaps the question is, do we want structured logging for network traces?

@mariomac
Copy link
Contributor

@grcevski as you prefer but I think it's fine to handle it in another PR

@rafaelroquetto
Copy link
Contributor Author

  • added pending tests
  • addressed review feedback (flag names, integration tests, etc...)
  • rebased

@rafaelroquetto rafaelroquetto self-assigned this Jul 18, 2024
@rafaelroquetto
Copy link
Contributor Author

@grcevski I still need to update the relevant docs, will do it very soon

@mariomac
Copy link
Contributor

As a design improvement, I'd maybe add a breaking change:

  1. Convert BEYLA_PRINT_TRACES to a string type.
  2. If BEYLA_PRINT_TRACES is "true" or, e.g., "text", use the normal print tracer.
  3. Replace BEYLA_PRINT_TRACES_JSON and BEYLA_PRINT_TRACES_JSON_INDENT by, for example, "json" and "json_indent" values of BEYLA_PRINT_TRACES.

Another option to avoid the breaking change could be to keep supporting BEYLA_PRINT_TRACES as boolean, but deprecate and remove it from the documentation, and add a similar new configuration option, e.g., BEYLA_TRACE_PRINTER, whose values could be like none, text, json and json_indent.

@rafaelroquetto
Copy link
Contributor Author

As a design improvement, I'd maybe add a breaking change:

1. Convert `BEYLA_PRINT_TRACES` to a `string` type.

2. If `BEYLA_PRINT_TRACES` is `"true"` or, e.g., `"text"`, use the normal print tracer.

3. Replace `BEYLA_PRINT_TRACES_JSON` and `BEYLA_PRINT_TRACES_JSON_INDENT` by, for example, `"json"` and `"json_indent"` values of `BEYLA_PRINT_TRACES`.

Another option to avoid the breaking change could be to keep supporting BEYLA_PRINT_TRACES as boolean, but deprecate and remove it from the documentation, and add a similar new configuration option, e.g., BEYLA_TRACE_PRINTER, whose values could be like none, text, json and json_indent.

@mariomac I'd lean towards the BEYLA_TRACE_PRINTER approach, with the deprecation of the other flag, IMHO if we can avoid a breaking change, that's better - I will get to it.

@rafaelroquetto
Copy link
Contributor Author

Removed code duplication as suggested by @marctc - cmdline option and docs change will follow.

The new JSON looks like this:

[
 {
  "type": "HTTP",
  "ignoreSpan": "(none)",
  "peer": "127.0.0.1",
  "peerPort": "32862",
  "host": "127.0.0.1",
  "hostPort": "8080",
  "status": "200",
  "traceID": "b59593dc743e002f15c4e28ba0ea81d2",
  "spanID": "6d6abe9fd8974be7",
  "parentSpanID": "0000000000000000",
  "flags": "1",
  "peerName": "localhost.lan",
  "hostName": "localhost.lan",
  "kind": "SERVER",
  "start": "1721409399099382",
  "handlerStart": "1721409399099558",
  "end": "1721409400099951",
  "duration": "1.000568948s",
  "durationUSec": "1000568",
  "handlerDuration": "1.000393577s",
  "handlerDurationUSec": "1000393",
  "attributes": {
   "clientAddr": "localhost.lan",
   "contentLen": "0",
   "method": "GET",
   "route": "/foo/*/hadsada",
   "serverAddr": "localhost.lan",
   "serverPort": "8080",
   "status": "200",
   "url": "/foo/baz/hadsada"
  }
 }
]

@rafaelroquetto
Copy link
Contributor Author

Documentation changes coming up next.

@@ -223,11 +226,26 @@ func (c *Config) Validate() error {
" purposes, you can also set BEYLA_NETWORK_PRINT_FLOWS=true")
}

if !c.TracePrinter.Valid() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add tests in config_test.go for this logic here?

pkg/export/debug/debug.go Show resolved Hide resolved
pkg/export/debug/debug.go Outdated Show resolved Hide resolved
pkg/internal/request/span.go Outdated Show resolved Hide resolved

require.NoError(t, err)

assert.Equal(t, s["type"], "HTTP")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can make this simpler by checking in one go, we have examples throughout the code, for example:

	assert.Equal(t, map[string]map[string]string{
		"/user/1234": {
			string(semconv.ServiceNameKey):      "svc-1",
			string(semconv.ServiceNamespaceKey): "ns",
			string(attr.ClientAddr):             "1.1.1.1",
			string(attr.HTTPRequestMethod):      "GET",
			string(attr.HTTPResponseStatusCode): "201",
			string(attr.HTTPUrlPath):            "/user/1234",
			string(attr.ServerPort):             "8080",
			string(attr.ServerAddr):             events["/user/1234"]["server.address"],
		},
		"/user/4321": {
			string(semconv.ServiceNameKey):      "svc-3",
			string(semconv.ServiceNamespaceKey): "ns",
			string(attr.ClientAddr):             "1.1.1.1",
			string(attr.HTTPRequestMethod):      "GET",
			string(attr.HTTPResponseStatusCode): "203",
			string(attr.HTTPUrlPath):            "/user/4321",
			string(attr.ServerPort):             "8080",
			string(attr.ServerAddr):             events["/user/1234"]["server.address"],
		},
	}, events)

pkg/export/debug/debug.go Outdated Show resolved Hide resolved
@marctc
Copy link
Contributor

marctc commented Jul 22, 2024

Removed code duplication as suggested by @marctc - cmdline option and docs change will follow.

Thanks, now looks much better! I was envisioning a conversion from OTEL span (not internal one) to JSON, but maybe that's way to complicated.

@@ -63,36 +112,184 @@ type PidInfo struct {
// REMINDER: any attribute here must be also added to the functions SpanOTELGetters,
// SpanPromGetters and getDefinitions in pkg/internal/export/metric/definitions.go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked and this file doesn't exist anymore. We can either remove this coment or point to another file. Maybe @mariomac can clarify here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah. It was moved to: pkg/export/attributes/attr_defs.go.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish Go had a Javadoc-like way of referencing functions and files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafaelroquetto would you mind changing those comments? thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marctc sorry, totally missed it - updated.

@rafaelroquetto rafaelroquetto changed the title Introduce JSON span printer WIP: Introduce JSON span printer Jul 22, 2024
@rafaelroquetto rafaelroquetto added do-not-merge WIP or something that musn't be merged wip labels Jul 22, 2024
@rafaelroquetto rafaelroquetto force-pushed the json_traces branch 2 times, most recently from 69dc012 to e4249a5 Compare July 24, 2024 13:10
Copy link
Contributor

@grcevski grcevski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking really good now. I think all we need to add is:

  • Some integration tests should use the "json" and some "json_indent" printer, to ensure we don't crash with those options.
  • Documentation.

@rafaelroquetto rafaelroquetto force-pushed the json_traces branch 4 times, most recently from 37c6968 to 061648c Compare July 24, 2024 20:19
@@ -51,13 +51,13 @@ To run Beyla, first set the following environment variables:
- The `OTEL_EXPORTER_OTLP_PROTOCOL`, `OTEL_EXPORTER_OTLP_ENDPOINT` and `OTEL_EXPORTER_OTLP_HEADERS` variables copied from the previous step.
- `BEYLA_OPEN_PORT`: the port the instrumented service is using (for example, `80` or `443`). If using the example service in the first section of this guide, set this variable to `8080`.

To facilitate local testing, set the `BEYLA_PRINT_TRACES=true` environment variable. This will cause Beyla to print traces to standard output.
To facilitate local testing, set the `BEYLA_TRACE_PRINTER=text` environment variable. This will cause Beyla to print traces to standard output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[Grafana.GoogleWill] Avoid using 'will'. Use present tense for statements that describe general behavior that's not associated with a particular time.

For more information, refer to https://developers.google.com/style/tense.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grcevski is this something that should be addressed as part of this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes 100%. You can reword it as something like:

To facilitate local testing, set the `BEYLA_TRACE_PRINTER=text` environment variable. When this option is set, Beyla will print traces in text format to the standard output.

@@ -53,7 +53,7 @@ To run Beyla, first set the following environment variables:
(for example, `80` or `443`). If using the example service in the
first section of this guide, set this variable to `8080`.

To facilitate local testing, set the `BEYLA_PRINT_TRACES=true` environment variable. This will cause Beyla to print traces to standard output.
To facilitate local testing, set the `BEYLA_TRACE_PRINTER=text` environment variable. This will cause Beyla to print traces to standard output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[Grafana.GoogleWill] Avoid using 'will'. Use present tense for statements that describe general behavior that's not associated with a particular time.

For more information, refer to https://developers.google.com/style/tense.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.

@@ -59,13 +59,13 @@ To run Beyla, first set the following environment variables:
(for example, `80` or `443`). If using the example service in the
first section of this guide, set this variable to `8080`.

To facilitate local testing, set the `BEYLA_PRINT_TRACES=true` environment variable. This will cause Beyla to print traces to standard output.
To facilitate local testing, set the `BEYLA_TRACE_PRINTER=text` environment variable. This will cause Beyla to print traces to standard output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[Grafana.GoogleWill] Avoid using 'will'. Use present tense for statements that describe general behavior that's not associated with a particular time.

For more information, refer to https://developers.google.com/style/tense.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.

@@ -51,7 +51,7 @@ To run Beyla, first set the following environment variables:
(for example, `80` or `443`). If using the example service in the
first section of this guide, set this variable to `8080`.

To facilitate local testing, set the `BEYLA_PRINT_TRACES=true` environment variable. This will cause Beyla to print traces to standard output.
To facilitate local testing, set the `BEYLA_TRACE_PRINTER=text` environment variable. This will cause Beyla to print traces to standard output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[Grafana.GoogleWill] Avoid using 'will'. Use present tense for statements that describe general behavior that's not associated with a particular time.

For more information, refer to https://developers.google.com/style/tense.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.

@@ -51,7 +51,7 @@ To run Beyla, first set the following environment variables:
(for example, `80` or `443`). If using the example service in the
first section of this guide, set this variable to `8080`.

To facilitate local testing, set the `BEYLA_PRINT_TRACES=true` environment variable. This will cause Beyla to print traces to standard output.
To facilitate local testing, set the `BEYLA_TRACE_PRINTER=text` environment variable. This will cause Beyla to print traces to standard output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[Grafana.GoogleWill] Avoid using 'will'. Use present tense for statements that describe general behavior that's not associated with a particular time.

For more information, refer to https://developers.google.com/style/tense.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.


<a id="printer"></a>

Prints any instrumented trace on the standard output (stdout). The value of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[Grafana.Spelling] Did you really mean 'stdout'? The Grafana dictionary might not know of this word yet. To add a new word, refer to Add words to the Grafana Labs dictionary. Alternatively, raise an issue and a maintainer will add it for you. For UI elements, use bold formatting. The spell checker doesn't check words with bold formatting. For paths; configuration; user input; code; class, method, and variable names; statuscodes; and console output, use code formatting. The spell checker doesn't check words with code formatting.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grcevski I might need some help here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason to keep (stdout).

| `json_indent` | prints an indented JSON object |


**The following option has been DEPRECATED.** *Use `trace_printer` instead.*
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added this to be explicit about the deprecation - not sure if this is what we usually do, so happy to remove it otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to mention the deprecation, we should only have documents for the new option, for the folks already using PRINT_TRACES=1 things will work as usual.

@rafaelroquetto rafaelroquetto removed do-not-merge WIP or something that musn't be merged wip labels Jul 24, 2024
Copy link
Contributor

@marctc marctc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff! Amazing first PR 🚀

@@ -51,13 +51,13 @@ To run Beyla, first set the following environment variables:
- The `OTEL_EXPORTER_OTLP_PROTOCOL`, `OTEL_EXPORTER_OTLP_ENDPOINT` and `OTEL_EXPORTER_OTLP_HEADERS` variables copied from the previous step.
- `BEYLA_OPEN_PORT`: the port the instrumented service is using (for example, `80` or `443`). If using the example service in the first section of this guide, set this variable to `8080`.

To facilitate local testing, set the `BEYLA_PRINT_TRACES=true` environment variable. This will cause Beyla to print traces to standard output.
To facilitate local testing, set the `BEYLA_TRACE_PRINTER=text` environment variable. When this option is set, Beyla will print traces in text format to the standard output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[Grafana.GoogleWill] Avoid using 'will'. Use present tense for statements that describe general behavior that's not associated with a particular time.

For more information, refer to https://developers.google.com/style/tense.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.

@@ -53,7 +53,7 @@ To run Beyla, first set the following environment variables:
(for example, `80` or `443`). If using the example service in the
first section of this guide, set this variable to `8080`.

To facilitate local testing, set the `BEYLA_PRINT_TRACES=true` environment variable. This will cause Beyla to print traces to standard output.
To facilitate local testing, set the `BEYLA_TRACE_PRINTER=text` environment variable. When this option is set, Beyla will print traces in text format to the standard output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[Grafana.GoogleWill] Avoid using 'will'. Use present tense for statements that describe general behavior that's not associated with a particular time.

For more information, refer to https://developers.google.com/style/tense.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.

@@ -47,13 +47,13 @@ To run Beyla, first set the following environment variables:
- The `OTEL_EXPORTER_OTLP_PROTOCOL`, `OTEL_EXPORTER_OTLP_ENDPOINT` and `OTEL_EXPORTER_OTLP_HEADERS` variables copied from the previous step.
- `BEYLA_OPEN_PORT`: the port the instrumented service is using (for example, `80` or `443`). If using the example service in the first section of this guide, set this variable to `8080`.

To facilitate local testing, set the `BEYLA_PRINT_TRACES=true` environment variable. This causes Beyla to print traces to the standard output.
To facilitate local testing, set the `BEYLA_TRACE_PRINTER=text` environment variable. When this option is set, Beyla will print traces in text format to the standard output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[Grafana.GoogleWill] Avoid using 'will'. Use present tense for statements that describe general behavior that's not associated with a particular time.

For more information, refer to https://developers.google.com/style/tense.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.

@@ -51,7 +51,7 @@ To run Beyla, first set the following environment variables:
(for example, `80` or `443`). If using the example service in the
first section of this guide, set this variable to `8080`.

To facilitate local testing, set the `BEYLA_PRINT_TRACES=true` environment variable. This will cause Beyla to print traces to standard output.
To facilitate local testing, set the `BEYLA_TRACE_PRINTER=text` environment variable. When this option is set, Beyla will print traces in text format to the standard output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[Grafana.GoogleWill] Avoid using 'will'. Use present tense for statements that describe general behavior that's not associated with a particular time.

For more information, refer to https://developers.google.com/style/tense.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.

@@ -51,7 +51,7 @@ To run Beyla, first set the following environment variables:
(for example, `80` or `443`). If using the example service in the
first section of this guide, set this variable to `8080`.

To facilitate local testing, set the `BEYLA_PRINT_TRACES=true` environment variable. This will cause Beyla to print traces to standard output.
To facilitate local testing, set the `BEYLA_TRACE_PRINTER=text` environment variable. When this option is set, Beyla will print traces in text format to the standard output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[Grafana.GoogleWill] Avoid using 'will'. Use present tense for statements that describe general behavior that's not associated with a particular time.

For more information, refer to https://developers.google.com/style/tense.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.

@@ -59,13 +59,13 @@ To run Beyla, first set the following environment variables:
(for example, `80` or `443`). If using the example service in the
first section of this guide, set this variable to `8080`.

To facilitate local testing, set the `BEYLA_PRINT_TRACES=true` environment variable. This will cause Beyla to print traces to standard output.
To facilitate local testing, set the `BEYLA_TRACE_PRINTER=text` environment variable. When this option is set, Beyla will print traces in text format to the standard output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[Grafana.GoogleWill] Avoid using 'will'. Use present tense for statements that describe general behavior that's not associated with a particular time.

For more information, refer to https://developers.google.com/style/tense.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.

@@ -47,13 +47,13 @@ To run Beyla, first set the following environment variables:
- The `OTEL_EXPORTER_OTLP_PROTOCOL`, `OTEL_EXPORTER_OTLP_ENDPOINT` and `OTEL_EXPORTER_OTLP_HEADERS` variables copied from the previous step.
- `BEYLA_OPEN_PORT`: the port the instrumented service is using (for example, `80` or `443`). If using the example service in the first section of this guide, set this variable to `8080`.

To facilitate local testing, set the `BEYLA_PRINT_TRACES=true` environment variable. This causes Beyla to print traces to the standard output.
To facilitate local testing, set the `BEYLA_TRACE_PRINTER=text` environment variable. When this option is set, Beyla will print traces in text format to the standard output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[Grafana.GoogleWill] Avoid using 'will'. Use present tense for statements that describe general behavior that's not associated with a particular time.

For more information, refer to https://developers.google.com/style/tense.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.

@rafaelroquetto rafaelroquetto changed the title WIP: Introduce JSON span printer Introduce JSON span printer Jul 25, 2024
@grcevski
Copy link
Contributor

@rafaelroquetto I just wanted to point out that tests are failing. There's some problem with the code you've added:

    debug_test.go:100: 
        	Error Trace:	/home/runner/work/beyla/beyla/pkg/export/debug/debug_test.go:100
        	Error:      	Not equal: 
        	            	expected: "2024-07-20 13:31:54.72013154 (25µs[20µs]) HTTP 200 method path [peer as peername:1234]->[host as hostname:5678] size:1024B svc=[ go] traceparent=[00-01020300000000000000000000000000-0102030000000000-01]\n"
        	            	actual  : "2024-07-25 13:31:23.72513123 (25µs[20µs]) HTTP 200 method path [peer as peername:1234]->[host as hostname:5678] size:1024B svc=[ go] traceparent=[00-01020300000000000000000000000000-0102030000000000-01]\n"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,2 +1,2 @@
        	            	-2024-07-20 13:31:54.72013154 (25µs[20µs]) HTTP 200 method path [peer as peername:1234]->[host as hostname:5678] size:1024B svc=[ go] traceparent=[00-01020300000000000000000000000000-0102030000000000-01]
        	            	+2024-07-25 13:31:23.72513123 (25µs[20µs]) HTTP 200 method path [peer as peername:1234]->[host as hostname:5678] size:1024B svc=[ go] traceparent=[00-01020300000000000000000000000000-0102030000000000-01]
        	            	 
        	Test:       	TestTracePrinterResolve_PrinterText

@rafaelroquetto rafaelroquetto merged commit bbb675b into main Jul 25, 2024
8 checks passed
@rafaelroquetto rafaelroquetto deleted the json_traces branch July 25, 2024 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider printing the traces in structured log output
6 participants