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

[feat][sdk-105] Add telemetry #313

Conversation

christianbuon
Copy link
Contributor

@christianbuon christianbuon commented Jul 10, 2024

Description of the change

This is adds support for the Telemetry feature (only given by user, automatic captures will be added later).

Overview

  • Telemetry is enabled by default by a RollbarTelemetryEventTracker with a capacity of 100 events, this capacity can be configured to a value between 0 and 100 by maximumTelemetryData from the CommonConfig.
  • A user can record log, manual, navigation or network events via Rollbar instance, this events are added in the next payload and removed from the queue.
  • A user can provide and use their own implementation of the TelemetryEventTracker(in this case the maximumTelemetryData from the CommonConfig would be ignored)

Example

Modify default maximum capacity

ConfigBuilder defaultConfig = ConfigBuilder
    .withAccessToken(accessToken)
    .maximumTelemetryData(10)

Maximum capacity surpased

ConfigBuilder defaultConfig = ConfigBuilder
    .withAccessToken(accessToken)
    .maximumTelemetryData(101) //Maximum is 100, so that value will be set

Override default TelemetryEventTracker

TelemetryEventTracker myTelemetryEventTracker = MyTelemetryEventTracker(...);

ConfigBuilder defaultConfig = ConfigBuilder.withAccessToken(accessToken)
    .maximumTelemetryData(10) //this is going to be ignored because a custom TelemetryEventTracker is set
    .telemetryEventTracker(myTelemetryEventTracker) 

Usage

Rollbar rollbar = Rollbar.instance();

rollbar.recordNavigationEventFor(Level.DEBUG, "MainActivity", "SecondActivity");
rollbar.recordManualEventFor(Level.ERROR, "some message");
rollbar.recordLogEventFor(Level.INFO, "some information");
rollbar.recordNetworkEventFor(Level.WARNING, "GET", "/example", "401");

rollbar.error("An error with telemetry events");
rollbar.error(new Exception("An error without telemetry events"));

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Maintenance
  • New release

Related issues

Shortcut stories and GitHub issues (delete irrelevant)

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers assigned
  • Issue from task tracker has a link to this pull request
  • Changes have been reviewed by at least one other engineer

@@ -794,7 +795,7 @@ public void debug(Throwable error, Map<String, Object> custom, String descriptio
}

/**
* Log an error at the level returned by {@link com.rollbar.notifier.Rollbar#level}.
* Log an error at the level returned by {@link Level}.
Copy link
Contributor

@csaba-ilonka-rollbar csaba-ilonka-rollbar Jul 16, 2024

Choose a reason for hiding this comment

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

The previous reference seem to be the correct one, since we are passing null here for level which is going to be replaced down the line with a default by the previously referenced level method.

Comment on lines 108 to 116
if test "$GITHUB_REPOSITORY" = "rollbar/rollbar-java" -a "$GITHUB_BASE_REF" = ""; then
openssl enc -aes-256-cbc -K "$SECRING_GPG_KEY" -iv "$SECRING_GPG_IV" -in "$ENCRYPTED_GPG_KEY_LOCATION" -out "$GPG_KEY_LOCATION" -d
fi &&
./.github/scripts/release.sh

- name: Cleanup Gradle cache
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
Copy link
Contributor

@csaba-ilonka-rollbar csaba-ilonka-rollbar Sep 25, 2024

Choose a reason for hiding this comment

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

Some of this stuff is not needed:

  • We are signing with a new key using a different method than before. The GPG keyring file no longer exists.
  • The conditions tested here are also part of the release script.
  • Cache is managed by the setup-java action.
Suggested change
if test "$GITHUB_REPOSITORY" = "rollbar/rollbar-java" -a "$GITHUB_BASE_REF" = ""; then
openssl enc -aes-256-cbc -K "$SECRING_GPG_KEY" -iv "$SECRING_GPG_IV" -in "$ENCRYPTED_GPG_KEY_LOCATION" -out "$GPG_KEY_LOCATION" -d
fi &&
./.github/scripts/release.sh
- name: Cleanup Gradle cache
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
./.github/scripts/release.sh

import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;

public class RollbarBaseTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

RollbarBaseTest sounds like a base class for tests, but this doesn't seem to be one. Could you find a different name for it that reflects what is being tested here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the problem is that I'm testing the new methods in RollbarBase
🤔 RollbarBaseNotifierTest ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm testing the new methods

and nothing else, so it'd be great if the name of the test class reflected that it's a collection of telemetry related test cases.

Copy link
Contributor

@csaba-ilonka-rollbar csaba-ilonka-rollbar left a comment

Choose a reason for hiding this comment

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

A few things to check again, but otherwise looking good 👍

* Set a {@link TelemetryEventTracker} implementation.
* Default: {@link RollbarTelemetryEventTracker} with a {@link TimestampProvider}.
* </p>
* @param telemetryEventTracker true to enable truncation.
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a copy/paste error.

* <p>
* Maximum Telemetry Events sent in a payload. Default is
* {@value RollbarTelemetryEventTracker#MAXIMUM_CAPACITY_FOR_TELEMETRY_EVENTS}.
* </p>
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you update the doc to explain that setting a custom tracker causes the value set here to be ignored?

* @param maximumTelemetryData max quantity of telemetry events sent.
* @return the builder instance.
*/
public ConfigBuilder maximumTelemetryData(int maximumTelemetryData) {
Copy link
Contributor

Choose a reason for hiding this comment

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

See comments on the other ConfigBuilder.

* Set a {@link TelemetryEventTracker} implementation.
* Default: {@link RollbarTelemetryEventTracker} with a {@link TimestampProvider}.
* </p>
* @param telemetryEventTracker true to enable truncation.
Copy link
Contributor

Choose a reason for hiding this comment

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

See comments on the other ConfigBuilder.

@buongarzoni buongarzoni merged commit 2bbb12c into rollbar:master Oct 3, 2024
4 checks passed
@buongarzoni buongarzoni mentioned this pull request Oct 3, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants