snowplow / snowplow-gtm-server-side-tag

A Google Tag Manager Server-side Tag template for sending events to a Snowplow Collector
Apache License 2.0
4 stars 2 forks source link

Standardize logs #6

Closed Bukashk0zzz closed 2 years ago

Bukashk0zzz commented 2 years ago

Init Query: Our enterprise clients use sGTM and they need to have the ability to log all requests and their responses for debugging purposes. And if there was an error in execution then properly parse it and send it to engineers.

Problem: Snowplow tag doesn't have the ability to log outgoing requests and their responses.

Solution:

At Stape we created a standard for all sGTM tag logs. Currently, all Stape tags already support our standardized logging format. And we already proposed our idea to other sGTM tags, and some of them already accepted this initiative.

Short description of the log standard rules: 1) Each log line must be a valid JSON object. (This allows parse logs by ELK, CloudWatch, Loki, etc.) 2) Each log object must contain at least Type, Name, TraceId fields. 3) Field Type must contain one of these values "Request", "Response", "Message". Witch helps easily filter logs. 4) TraceId must contain a unique identifier of the current incoming request. This field is used for stitching all logs done by all tags/clients during one request. 5) Name must contain tag name.

Here is an example of code from one of the tags: https://github.com/stape-io/facebook-tag/blob/main/template.js#L63

And here is an example of UI:

Screenshot 2022-05-15 at 11 11 54

I hope you accept the idea of this initiative as we used your tags a lot and this will allow us to use the version from the template gallery instead our own repo.

If you like this idea I prepare PR with changes to your tag.

p.s. Thanks for a great open-source product and great sGTM template.

paulboocock commented 2 years ago

This certainly seems to be a reasonable idea and I'd be more than happy to accept a PR (and others across our other Tags).

I should be able to get someone on the team to take a look at the PR reasonably quickly once the PR is open 👍