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: Add device last connected metrics #1515

Merged
merged 5 commits into from
Sep 27, 2023

Conversation

lindseysimple
Copy link
Contributor

@lindseysimple lindseysimple commented Sep 20, 2023

fixes #1470. Add device last connected metrics to Get/Set command.

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/device-sdk-go/blob/main/.github/Contributing.md

PR Checklist

Please check if your PR fulfills the following requirements:

  • I am not introducing a breaking change (if you are, flag in conventional commit message with BREAKING CHANGE: describing the break)
  • I am not introducing a new dependency (add notes below if you are)
  • I have added unit tests for the new feature or bug fix (if not, why?)
  • I have fully tested (add details below) this the new feature or bug fix (if not, why?)
  • I have opened a PR for the related docs change (if not, why?) - feat: Add LastConnected metric to common config edgex-docs#1231

Testing Instructions

New Dependency Instructions (If applicable)

fixes edgexfoundry#1470. Add device last connected metrics to Get/Set command.

Signed-off-by: Lindsey Cheng <beckysocute@gmail.com>
Copy link
Member

@cloudxxx8 cloudxxx8 left a comment

Choose a reason for hiding this comment

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

Use URL escape for device name if configuration.Service.EnableNameFieldEscape is true
Reference:
https://github.com/edgexfoundry/device-sdk-go/pull/1502/files
https://github.com/edgexfoundry/device-sdk-go/pull/1506/files

Copy link
Member

@cloudxxx8 cloudxxx8 left a comment

Choose a reason for hiding this comment

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

async value should also be handled

- Register/Unregister LastConnected on add/remove device cache.
- Update LastConnected for async reading

Signed-off-by: Lindsey Cheng <beckysocute@gmail.com>
@lindseysimple
Copy link
Contributor Author

Change's made for URL escape for device name and update LastConnected metric for async value.

Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

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

Nice Job!! Just a few comments.

internal/cache/devices.go Outdated Show resolved Hide resolved
internal/cache/devices.go Outdated Show resolved Hide resolved
internal/cache/devices.go Outdated Show resolved Hide resolved
Add unit tests for new lastConnected methods in deviceCache.

Signed-off-by: Lindsey Cheng <beckysocute@gmail.com>
@lindseysimple lindseysimple self-assigned this Sep 25, 2023
Signed-off-by: Lindsey Cheng <beckysocute@gmail.com>
registeredName := strings.Replace(lastConnectedPrefix, deviceNameText, deviceName, 1)

err := metricsManager.Register(registeredName, metric, map[string]string{"device": deviceName})
err := metricsManager.Register(registeredName, metric, nil)
Copy link
Member

Choose a reason for hiding this comment

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

The tag is still needed. This allows for filtering on a dashboard such as Grafana.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, tag added back. Thanks.

Add back the device tag to the LastConnected metric.

Signed-off-by: Lindsey Cheng <beckysocute@gmail.com>
Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

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

LGTM

@lenny-goodell lenny-goodell merged commit 1f88585 into edgexfoundry:main Sep 27, 2023
3 checks passed
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 this pull request may close these issues.

Device Last Connected
3 participants