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

Logging HTTP API calls that are invoked by the FHIR Engine while syncing #1426

Closed
joiskash opened this issue May 27, 2022 · 1 comment · Fixed by #1570
Closed

Logging HTTP API calls that are invoked by the FHIR Engine while syncing #1426

joiskash opened this issue May 27, 2022 · 1 comment · Fixed by #1570
Assignees
Labels
effort:small Small effort - 2 days P1 High priority issue type:enhancement New feature or request

Comments

@joiskash
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
We have a requirement to log HTTP API calls. Logging is needed to analyze data packet size, time taken for API calls, failures etc.

Describe the solution you'd like
We would like to have an opening to pass an HTTPLoggingInterceptor to okHttpClient used by the FHIR engine.

Describe alternatives you've considered
No alternatives, open to suggestions.

@joiskash
Copy link
Collaborator Author

We have modified the RemoteFhirService.kt class by adding a custom HttpLoggingInterceptor that logs Http calls at the HttpLoggingInterceptor.Level.HEADERS .

      val customLogger =
        HttpLoggingInterceptor.Logger {
          try {
            writeToFile(fullFileName, it)
          } catch (exception: FileNotFoundException) {
            println("File not found")
          }
        }
      val logger = HttpLoggingInterceptor(customLogger)
      logger.level = HttpLoggingInterceptor.Level.HEADERS

      val client =
        OkHttpClient.Builder()
          .apply {
            connectTimeout(networkConfiguration.connectionTimeOut, TimeUnit.SECONDS)
            readTimeout(networkConfiguration.readTimeOut, TimeUnit.SECONDS)
            writeTimeout(networkConfiguration.writeTimeOut, TimeUnit.SECONDS)
            addInterceptor(logger)
            .
            .
            .

More details can be found here :

https://github.com/joiskash/android-fhir/blob/kj/fork-anc/engine/src/main/java/com/google/android/fhir/sync/remote/RemoteFhirService.kt

@Tarun-Bhardwaj Tarun-Bhardwaj added FHIR engine P1 High priority issue effort:small Small effort - 2 days and removed Triage labels Jul 5, 2022
@aditya-07 aditya-07 self-assigned this Jul 12, 2022
@aditya-07 aditya-07 added the type:enhancement New feature or request label Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort:small Small effort - 2 days P1 High priority issue type:enhancement New feature or request
Projects
Status: Complete
Development

Successfully merging a pull request may close this issue.

3 participants