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

Provide a mechanism to add arbitrary fields to the Honeycomb event #3

Closed
kvrhdn opened this issue Apr 27, 2020 · 6 comments · Fixed by #18
Closed

Provide a mechanism to add arbitrary fields to the Honeycomb event #3

kvrhdn opened this issue Apr 27, 2020 · 6 comments · Fixed by #18

Comments

@kvrhdn
Copy link
Contributor

kvrhdn commented Apr 27, 2020

buildevents allows you to provide arbitrary key-value data using the BUILDEVENT_FILE environment variable. gha-buildevents uses this to send metadata about the GitHub Actions workflow.

We should provide a mechanism to allow users to provide additional fields.

This syntax would be great:

- uses: kvrhdn/gha-buildevents@master
  with:
    apikey: ${{ secrets.APIKEY }}
    dataset: my-dataset
    additional-fields:
      buildVersion: BUILD_VERSION
      project: my-project
      ...
@kvrhdn kvrhdn changed the title Provide a mechanism to arbitraty fields to the Honeycomb event Provide a mechanism to add arbitrary fields to the Honeycomb event Apr 29, 2020
@kvrhdn
Copy link
Contributor Author

kvrhdn commented Apr 30, 2020

It could be interesting to allow steps to add to this file as well. I.e. in case we make a gha-buildevents-step:

- uses: kvrhdn/gha-buildevents-step@master
  with:
    name: My step
    additional-fields:
      buildResult: success

@DavidS
Copy link
Contributor

DavidS commented Nov 24, 2020

That would be great! As it stands, even trying to used the buildevent file is not really reliable as some spans don't pick up the values.

@kvrhdn
Copy link
Contributor Author

kvrhdn commented Nov 25, 2020

I currently don't have any bandwidth to work on this, but I'll leave some notes here for anyone that wants to pick this up.

This issue can be divided into two problems:

  1. we need a mechanism to pass arbitrary fieds to the action
  2. we need a mechanism to pass these fields to the buildevents binary

For 2) we already have some infrastructure in place: buildevents already reads a file buildevents.txt that contains values in the logfmt format.
This file is created here:

For 1) there is currently no solution. Additionally, I think the action inputs are currently limited to strings only. So the following is not possible:

- uses: kvrhdn/gha-buildevents
  with:
    # snip
    additional-fields:
      - app: my-app
      - version: 0.0.1

Instead, we'll have to pass a text block I think:

- uses: kvrhdn/gha-buildevents
  with:
    # snip
    additional-fields: |
      app=my-app
      version=0.0.1

But... can we validate this? (Do we have to validate this?)

I did something similar in my tfe-run action to pass a list of variables to Terraform:

DavidS added a commit to DavidS/gha-buildevents that referenced this issue Dec 14, 2020
This allows users of this action to specify additional fields through the
file at $BUILDEVENT_FILE. Any values specified in there override the
defaults provided by gha-buildevents.

This fixes honeycombio#3.
@DavidS
Copy link
Contributor

DavidS commented Dec 14, 2020

I was thinking about a simpler alternative: #18 changes the addFields method to not unconditionally overwrite the BUILDEVENT_FILE. That way folks can add to that without issues.

DavidS added a commit to DavidS/gha-buildevents that referenced this issue Dec 14, 2020
This allows users of this action to specify additional fields through the
file at $BUILDEVENT_FILE. Any values specified in there override the
defaults provided by gha-buildevents.

This fixes honeycombio#3.
@kvrhdn
Copy link
Contributor Author

kvrhdn commented Dec 16, 2020

I was thinking about a simpler alternative: #18 changes the addFields method to not unconditionally overwrite the BUILDEVENT_FILE. That way folks can add to that without issues.

Yeah, I think this will work well. gha-buildevents will only create a buildevents.txt file in the post section. So you are free to create your own file and override the env var BUILDEVENT_FILE until then.
I can envision there might be an issue if we create a file at the start of the build and a user later sets a different value in BUILDEVENT_FILE.

@kvrhdn kvrhdn mentioned this issue Dec 16, 2020
2 tasks
@DavidS
Copy link
Contributor

DavidS commented Dec 17, 2020

I can envision there might be an issue if we create a file at the start of the build and a user later sets a different value in BUILDEVENT_FILE.

Oh, that's a good point, I didn't consider this case. It might be worthwhile pointing that out in documentation that it's recommended to "set and forget" the value for BUILDEVENT_FILE at the very top-level to avoid any weird interactions. Given that I'd expect most folks to use a top-level env: key to set this, I'm not too worried.

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 a pull request may close this issue.

2 participants