Skip to content

Conversation

@tobiasstadler
Copy link
Contributor

@tobiasstadler tobiasstadler commented Feb 14, 2022

Motivation/summary

For metricsets the service.version is only overwritten if also service.name is given (see #6407 (comment)). It should be the same for transactions, errors, ...

Checklist

For functional changes, consider:

  • Is it observable through the addition of either logging or metrics?
  • Is its use being published in telemetry to enable product improvement?
  • Have system tests been added to avoid regression?

How to test these changes

Ingest a transaction that only contains a service.version, but no service.name

@ghost
Copy link

ghost commented Feb 14, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-02-15T12:20:11.319+0000

  • Duration: 61 min 31 sec

Test stats 🧪

Test Results
Failed 0
Passed 5635
Skipped 19
Total 5654

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /hey-apm : Run the hey-apm benchmark.

  • /package : Generate and publish the docker images.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@mergify
Copy link
Contributor

mergify bot commented Feb 14, 2022

This pull request does not have a backport label. Could you fix it @tobiasstadler? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-7.x is the label to automatically backport to the 7.x branch.
  • backport-7./d is the label to automatically backport to the 7./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@mergify mergify bot added the backport-skip Skip notification from the automated backport with mergify label Feb 14, 2022
Copy link
Member

@axw axw left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@axw
Copy link
Member

axw commented Feb 15, 2022

/test

@axw axw added the v8.2.0 label Feb 15, 2022
@tobiasstadler
Copy link
Contributor Author

@axw I fixed the tests. make test and make system-test finished successfully on my machine.

@tobiasstadler
Copy link
Contributor Author

Since this is some kind of bug fix, should it be back ported to 8.1?

@axw
Copy link
Member

axw commented Feb 15, 2022

@tobiasstadler we have already frozen 8.1. Although it's arguable a bug fix, I'd prefer that it waits for 8.2. Is it causing any issues for you?

@axw axw enabled auto-merge (squash) February 15, 2022 12:19
@tobiasstadler
Copy link
Contributor Author

No, 8.2 is fine.

@tobiasstadler
Copy link
Contributor Author

run elasticsearch-ci/docs

@axw axw disabled auto-merge February 16, 2022 01:01
@axw axw merged commit 4fa6b6a into elastic:main Feb 16, 2022
@tobiasstadler
Copy link
Contributor Author

Thank You!

@tobiasstadler tobiasstadler deleted the service-version-needs-service-name branch February 16, 2022 06:13
@stuartnelson3
Copy link
Contributor

testing this was unsuccessful with 772e8c1

  1. start elasticsearch/kibana
  2. start apm-server
  3. ingest span + transaction with the following program:
package main

import (
	"context"
	"fmt"
	"os"
	"time"

	"go.elastic.co/apm/v2"
)

func main() {
	version := "undefined"
	if len(os.Args) > 1 {
		version = os.Args[1]
	}
	name := fmt.Sprintf("apm-server-%s", version)

	tracer, err := apm.NewTracer("", "1.0.0")
	if err != nil {
		panic(err)
	}
	tx := tracer.StartTransaction("name", "type")
	ctx := apm.ContextWithTransaction(context.Background(), tx)
	span, ctx := apm.StartSpan(ctx, "name", "type")
	span.End()
	tx.End()
	<-time.After(time.Second)
	tracer.Flush(nil)
	fmt.Printf("%s: %+v\n", name, tracer.Stats())
}
  1. check the transaction document has no service.version set. In the console:
GET traces-apm-default/_search
{
  "sort" : [{ "@timestamp" : "desc" }]
}

service.name seems to have been set to the default value (the binary name) from the agent, and therefore service.version was also set.
I attempted to injest an ndjson document without a service.name set, but the apm server rejected it (validation error: metadata: service: 'name': validation rule 'minLength(1)' violated)

@axw
Copy link
Member

axw commented Apr 1, 2022

@stuartnelson3 I'm not sure that your tests cover Tobias's changes.

The changes are related to overriding service.name and service.version at the event level, which the Go agent's API doesn't support. Your test above only affects the service.name and service.version set at the stream (metadata) level.

I've verified this with 8.2.0-BC1, using https://github.com/elastic/apm-server/blob/main/testdata/intake-v2/transactions_spans.ndjson#L2.

The first transaction overrides service.name, but does not specify service.version. I confirmed the service.name field is set to "serviceabc" but there is no service.version field set.

I then modified the document to override service.version but not service.name, and confirmed that neither are used and that service.name and service.version from metadata are both used.

Finally, I confirmed that if both service.name and service.version are specified in the overrides, both are used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-skip Skip notification from the automated backport with mergify test-plan test-plan-ok v8.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants