Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

klogs-plugin: add links integration #444

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

staffbase-robert
Copy link
Contributor

@staffbase-robert staffbase-robert commented Nov 28, 2022

This PR solves the issue #255 for the klogs plugin. It allows users to specify a column name and a path to direct users to a different plugin inside kobs or any other place (grafana, jaeger, etc.). It's possible to:

  • specify a placeholder for the value with <<value>> (this is replaced with the actual document value for the specific column) and/or
  • specify a placeholder for timeStart and timeEnd (with <<timeStart>> and <<timeEnd>>). This can be useful to create a query for a different platform that benefits from limited time-ranges (e.g jaeger or grafana).

@@ -10,9 +10,28 @@ import (
"go.uber.org/zap"
)

func (i *instance) enrichAutolinks(fields []Field) []Field {
autolinkIntegrations := make([]IntegrationAutolinks, 0)
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 don't expect this slice to become huge, same with i.integrations. If desired we can filter the autolinkIntegrations slice outside of this method (which is invoked on every request). Furthermore I could make it a map[string]IntegrationAutolinks with the columnName as key. This would further reduce the overhead in L22-L26.

return;
}

path = path.replaceAll('<<value>>', value);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could also use a pattern here instead. For example:

# autolink.path = /goto?foo=$1
# autolink.match = bar-(.*)

value = bar-1234
# resolves to
path = /goto?foo=1234

@codecov-commenter
Copy link

Codecov Report

Merging #444 (69d1d23) into main (3fac1ad) will decrease coverage by 0.01%.
The diff coverage is 38.46%.

@@            Coverage Diff             @@
##             main     #444      +/-   ##
==========================================
- Coverage   43.77%   43.76%   -0.02%     
==========================================
  Files         143      143              
  Lines       12396    12424      +28     
==========================================
+ Hits         5426     5437      +11     
- Misses       6829     6846      +17     
  Partials      141      141              
Impacted Files Coverage Δ
plugins/plugin-klogs/cmd/klogs.go 0.00% <0.00%> (ø)
plugins/plugin-klogs/pkg/instance/logs.go 0.00% <0.00%> (ø)
plugins/plugin-klogs/pkg/instance/instance.go 36.18% <9.09%> (+0.42%) ⬆️
plugins/plugin-klogs/pkg/instance/helpers.go 98.77% <89.47%> (-1.23%) ⬇️
plugins/plugin-klogs/pkg/instance/aggregation.go 7.42% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@staffbase-robert staffbase-robert marked this pull request as ready for review November 29, 2022 08:16
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants